from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

op = webdriver.ChromeOptions()
op.add_experimental_option('excludeSwitches', ['enable-automation'])
op.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=op)

driver.get("http://news.baidu.com/")

firstnewsele = driver.find_element(By.XPATH, "//div[@id='pane-news']/div/ul/li[1]/strong/a")
content = firstnewsele.text
firstnewsele.click()
sleep(5)

current = driver.current_window_handle
all_handles = driver.window_handles
print("current,",current)
print("----------------")
print(all_handles)

driver.switch_to.window(all_handles[1])



print(driver.title)
print("current,",driver.current_window_handle)

assert content in driver.title

driver.quit()

